package lambda_expression.stream;

import lambda_expression.method_reference.Employee;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class PeekStreamTest {

    public static void main(String[] args) {
        List<Employee> employeeList = new ArrayList<Employee>();
        employeeList.add(new Employee(1, "ABC", 100, 1120.0));
        employeeList.add(new Employee(2, "DEF", 200, 220.0));
        employeeList.add(new Employee(3, "QWE", 300, 330.0));
        employeeList.add(new Employee(4, "RTY", 400, 10.0));
        employeeList.add(new Employee(4, "POI", 200, 10.0));
        employeeList.add(new Employee(4, "UYT", 300, 10.0));

        // 从一个流变成一个新的流
        employeeList.stream()
                .peek(x -> x.setAge(x.getAge()+100))
                .sorted(Comparator.comparing(Employee::getSalary))
                .forEach(item -> {
                    System.out.println(item.toString());
                });

    }
}
